package dev.ece.suit.hexmap;

import dev.ece.core.light.Material;
import dev.ece.core.texture.Texture;
import dev.ece.util.lib.Vector2f;
import dev.ece.util.lib.Vector3f;

/**
 * 地形
 * @author 潜行的虚影
 *
 */
public interface Terrain {

	/**
	 * 材质
	 * @return
	 */
	public Material getMaterial();
	
	default void glCellShader(HexMapCellShader cellShader, TerrainModelCreator terrainFactory) {
		cellShader.glTexture(texture(terrainFactory));
		cellShader.glMaterial(getMaterial());
	}
	
	default float height(MapCellCreator cellCreator, Vector3f vertex, Vector2f uv) {
		return 0.1f;
	}
	
	default float[] height(MapCellCreator cellCreator, Vector3f[] vertice, Vector2f[] uv) {
		float[] heights = new float[vertice.length];
		for(int i=0; i<vertice.length; i++) {
			heights[i] = height(cellCreator, vertice[i], uv[i]);
		}
		return heights;
	};
	
	default Texture texture(TerrainModelCreator terrainFactory) {
		return terrainFactory.getTextures()[getTextureIndex()];
	}
	
	int getTextureIndex();
	
	boolean hasWater();
	
	default float getWaterHeight() {
		return 0;
	}
	
}
